Skip to content

Conversation

@michael-yuji
Copy link
Member

Suspend all other threads first before closing file descriptors and exec.

Motivation:

See #8197 #8180, swift run can crash due to race condition between libdispatch controlled threads. To properly mitigate this, suspend all other threads (including those managed by libdispatch) before closing the file descriptors.

Modifications:

Call pthread_suspend_all_np before closing file descriptors, this api is not portable but exists on both FreeBSD and OpenBSD. However, since the Glibc overlay for OpenBSD does not include <pthread_np.h>, we guard this and make it available for FreeBSD only.

@michael-yuji
Copy link
Member Author

@swift-ci please test

@jakepetroules jakepetroules enabled auto-merge (rebase) January 26, 2025 06:18
@jakepetroules jakepetroules merged commit 6aa009f into swiftlang:main Jan 26, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants